#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_

#include <QCloseEvent>
#include <QMainWindow>
#include <QSystemTrayIcon>
#include "views/IMainWindowView.h"

namespace Ui
{
	class MainWindow;
}

class MainWindowPresenter;
class ServiceLocator;

class MainWindow : public QMainWindow, public IMainWindowView
{
	Q_OBJECT

public:
	MainWindow(ServiceLocator *serviceLocator, QWidget *parent = 0, Qt::WindowFlags flags = 0);
	virtual ~MainWindow();

	void init();

	// IMainWindowView.
	Repository *showAddRepositoryDialog();
	void toggleVisibility();
	void hideWindow();
	void closeWindow();

private:
	Ui::MainWindow *ui;
	QSystemTrayIcon *trayIcon;
	MainWindowPresenter *presenter;

	void closeEvent(QCloseEvent *event);

	void createUi();
	void createWidgets();
	void createTrayIcon();
private slots:
	void on_addRepositoryAction_triggered();
	void on_removeRepositoryAction_triggered();
	void on_editRepositoryAction_triggered();
	void on_preferencesAction_triggered();
	void on_exitAction_triggered();

	void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
};

#endif /* MAINWINDOW_H_ */
